package cn.ibizlab.odoo.core.odoo_hr.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Ihr_leave;
import cn.ibizlab.odoo.core.odoo_hr.domain.Hr_leave;
import cn.ibizlab.odoo.core.odoo_hr.filter.Hr_leaveSearchContext;
import cn.ibizlab.odoo.core.odoo_hr.service.IHr_leaveService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[休假] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Hr_leaveServiceImpl implements IHr_leaveService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Ihr_leaveClientService hr_leaveClientService;

    @Override
    public boolean update(Hr_leave hr_leave) {
        boolean bOk = false ;
        Ihr_leave clientModel = this.convert2Model(hr_leave,null);
        hr_leaveClientService.update(clientModel) ;
        this.convert2Domain(clientModel,hr_leave) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void updateBatch(List<Hr_leave> hr_leaves, int batchSize) {

        //hr_leaveClientService.updateBatch(hr_leaves,batchSize) ;

    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //hr_leaveClientService.removeBatch(hr_leaves) ;

    }

    @Override
    public boolean create(Hr_leave hr_leave) {
        boolean bOk = false ;
        Ihr_leave clientModel = this.convert2Model(hr_leave,null);
        hr_leaveClientService.create(clientModel) ;
        this.convert2Domain(clientModel,hr_leave);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void createBatch(List<Hr_leave> hr_leaves, int batchSize) {

                        //hr_leaveClientService.createBatch(hr_leaves,batchSize) ;

    }

    @Override
    public Hr_leave get(Integer id) {
        Ihr_leave clientModel = hr_leaveClientService.createModel();
        clientModel.setId(id);
        hr_leaveClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Hr_leave get(Hr_leave hr_leave) {
        Hr_leave rethr_leave = this.get(hr_leave.getId()) ;
    	BeanCopier copier=BeanCopier.create(rethr_leave.getClass(), hr_leave.getClass(), false);
        copier.copy(rethr_leave, hr_leave, null);
        return hr_leave ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Ihr_leave clientModel = hr_leaveClientService.createModel();
        clientModel.setId(id);
        hr_leaveClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Hr_leave> searchDefault(Hr_leaveSearchContext context) {
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据活动查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_meeting(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据HR 部门查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_department(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工类别查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_category(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_employee(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_first_approver(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_manager(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_second_approver(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据休假类型查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_holiday_status(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据休假查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_parent(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_mode_company(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_create(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_user(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_leave> selectByOdoo_write(Integer id){
        Hr_leaveSearchContext context = new Hr_leaveSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_leave> list = new ArrayList<Hr_leave>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_leave> clientModelList = hr_leaveClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_leave clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_leave>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Ihr_leave convert2Model(Hr_leave domain , Ihr_leave model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = hr_leaveClientService.createModel() ;
        }

         if(domain.getHoliday_typeDirtyFlag())
            model.setHoliday_type(domain.getHoliday_type());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getRequest_date_fromDirtyFlag())
            model.setRequest_date_from(domain.getRequest_date_from());
         if(domain.getNotesDirtyFlag())
            model.setNotes(domain.getNotes());
         if(domain.getNumber_of_daysDirtyFlag())
            model.setNumber_of_days(domain.getNumber_of_days());
         if(domain.getRequest_date_toDirtyFlag())
            model.setRequest_date_to(domain.getRequest_date_to());
         if(domain.getRequest_unit_halfDirtyFlag())
            model.setRequest_unit_half(domain.getRequest_unit_half());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getNumber_of_days_displayDirtyFlag())
            model.setNumber_of_days_display(domain.getNumber_of_days_display());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getRequest_hour_fromDirtyFlag())
            model.setRequest_hour_from(domain.getRequest_hour_from());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getPayslip_statusDirtyFlag())
            model.setPayslip_status(domain.getPayslip_status());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getRequest_unit_hoursDirtyFlag())
            model.setRequest_unit_hours(domain.getRequest_unit_hours());
         if(domain.getDate_toDirtyFlag())
            model.setDate_to(domain.getDate_to());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getCan_resetDirtyFlag())
            model.setCan_reset(domain.getCan_reset());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getNumber_of_hours_displayDirtyFlag())
            model.setNumber_of_hours_display(domain.getNumber_of_hours_display());
         if(domain.getRequest_unit_customDirtyFlag())
            model.setRequest_unit_custom(domain.getRequest_unit_custom());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getReport_noteDirtyFlag())
            model.setReport_note(domain.getReport_note());
         if(domain.getRequest_hour_toDirtyFlag())
            model.setRequest_hour_to(domain.getRequest_hour_to());
         if(domain.getDate_fromDirtyFlag())
            model.setDate_from(domain.getDate_from());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getLinked_request_idsDirtyFlag())
            model.setLinked_request_ids(domain.getLinked_request_ids());
         if(domain.getCan_approveDirtyFlag())
            model.setCan_approve(domain.getCan_approve());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getRequest_date_from_periodDirtyFlag())
            model.setRequest_date_from_period(domain.getRequest_date_from_period());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getDuration_displayDirtyFlag())
            model.setDuration_display(domain.getDuration_display());
         if(domain.getMode_company_id_textDirtyFlag())
            model.setMode_company_id_text(domain.getMode_company_id_text());
         if(domain.getLeave_type_request_unitDirtyFlag())
            model.setLeave_type_request_unit(domain.getLeave_type_request_unit());
         if(domain.getEmployee_id_textDirtyFlag())
            model.setEmployee_id_text(domain.getEmployee_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getMeeting_id_textDirtyFlag())
            model.setMeeting_id_text(domain.getMeeting_id_text());
         if(domain.getSecond_approver_id_textDirtyFlag())
            model.setSecond_approver_id_text(domain.getSecond_approver_id_text());
         if(domain.getCategory_id_textDirtyFlag())
            model.setCategory_id_text(domain.getCategory_id_text());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getFirst_approver_id_textDirtyFlag())
            model.setFirst_approver_id_text(domain.getFirst_approver_id_text());
         if(domain.getHoliday_status_id_textDirtyFlag())
            model.setHoliday_status_id_text(domain.getHoliday_status_id_text());
         if(domain.getManager_id_textDirtyFlag())
            model.setManager_id_text(domain.getManager_id_text());
         if(domain.getParent_id_textDirtyFlag())
            model.setParent_id_text(domain.getParent_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getValidation_typeDirtyFlag())
            model.setValidation_type(domain.getValidation_type());
         if(domain.getDepartment_id_textDirtyFlag())
            model.setDepartment_id_text(domain.getDepartment_id_text());
         if(domain.getManager_idDirtyFlag())
            model.setManager_id(domain.getManager_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getParent_idDirtyFlag())
            model.setParent_id(domain.getParent_id());
         if(domain.getMode_company_idDirtyFlag())
            model.setMode_company_id(domain.getMode_company_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getSecond_approver_idDirtyFlag())
            model.setSecond_approver_id(domain.getSecond_approver_id());
         if(domain.getMeeting_idDirtyFlag())
            model.setMeeting_id(domain.getMeeting_id());
         if(domain.getHoliday_status_idDirtyFlag())
            model.setHoliday_status_id(domain.getHoliday_status_id());
         if(domain.getDepartment_idDirtyFlag())
            model.setDepartment_id(domain.getDepartment_id());
         if(domain.getEmployee_idDirtyFlag())
            model.setEmployee_id(domain.getEmployee_id());
         if(domain.getCategory_idDirtyFlag())
            model.setCategory_id(domain.getCategory_id());
         if(domain.getFirst_approver_idDirtyFlag())
            model.setFirst_approver_id(domain.getFirst_approver_id());
        return model ;
    }

    public Hr_leave convert2Domain( Ihr_leave model ,Hr_leave domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Hr_leave();
        }

        if(model.getHoliday_typeDirtyFlag())
            domain.setHoliday_type(model.getHoliday_type());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getRequest_date_fromDirtyFlag())
            domain.setRequest_date_from(model.getRequest_date_from());
        if(model.getNotesDirtyFlag())
            domain.setNotes(model.getNotes());
        if(model.getNumber_of_daysDirtyFlag())
            domain.setNumber_of_days(model.getNumber_of_days());
        if(model.getRequest_date_toDirtyFlag())
            domain.setRequest_date_to(model.getRequest_date_to());
        if(model.getRequest_unit_halfDirtyFlag())
            domain.setRequest_unit_half(model.getRequest_unit_half());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getNumber_of_days_displayDirtyFlag())
            domain.setNumber_of_days_display(model.getNumber_of_days_display());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getRequest_hour_fromDirtyFlag())
            domain.setRequest_hour_from(model.getRequest_hour_from());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getPayslip_statusDirtyFlag())
            domain.setPayslip_status(model.getPayslip_status());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getRequest_unit_hoursDirtyFlag())
            domain.setRequest_unit_hours(model.getRequest_unit_hours());
        if(model.getDate_toDirtyFlag())
            domain.setDate_to(model.getDate_to());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getCan_resetDirtyFlag())
            domain.setCan_reset(model.getCan_reset());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getNumber_of_hours_displayDirtyFlag())
            domain.setNumber_of_hours_display(model.getNumber_of_hours_display());
        if(model.getRequest_unit_customDirtyFlag())
            domain.setRequest_unit_custom(model.getRequest_unit_custom());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getReport_noteDirtyFlag())
            domain.setReport_note(model.getReport_note());
        if(model.getRequest_hour_toDirtyFlag())
            domain.setRequest_hour_to(model.getRequest_hour_to());
        if(model.getDate_fromDirtyFlag())
            domain.setDate_from(model.getDate_from());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getLinked_request_idsDirtyFlag())
            domain.setLinked_request_ids(model.getLinked_request_ids());
        if(model.getCan_approveDirtyFlag())
            domain.setCan_approve(model.getCan_approve());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getRequest_date_from_periodDirtyFlag())
            domain.setRequest_date_from_period(model.getRequest_date_from_period());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getDuration_displayDirtyFlag())
            domain.setDuration_display(model.getDuration_display());
        if(model.getMode_company_id_textDirtyFlag())
            domain.setMode_company_id_text(model.getMode_company_id_text());
        if(model.getLeave_type_request_unitDirtyFlag())
            domain.setLeave_type_request_unit(model.getLeave_type_request_unit());
        if(model.getEmployee_id_textDirtyFlag())
            domain.setEmployee_id_text(model.getEmployee_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getMeeting_id_textDirtyFlag())
            domain.setMeeting_id_text(model.getMeeting_id_text());
        if(model.getSecond_approver_id_textDirtyFlag())
            domain.setSecond_approver_id_text(model.getSecond_approver_id_text());
        if(model.getCategory_id_textDirtyFlag())
            domain.setCategory_id_text(model.getCategory_id_text());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getFirst_approver_id_textDirtyFlag())
            domain.setFirst_approver_id_text(model.getFirst_approver_id_text());
        if(model.getHoliday_status_id_textDirtyFlag())
            domain.setHoliday_status_id_text(model.getHoliday_status_id_text());
        if(model.getManager_id_textDirtyFlag())
            domain.setManager_id_text(model.getManager_id_text());
        if(model.getParent_id_textDirtyFlag())
            domain.setParent_id_text(model.getParent_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getValidation_typeDirtyFlag())
            domain.setValidation_type(model.getValidation_type());
        if(model.getDepartment_id_textDirtyFlag())
            domain.setDepartment_id_text(model.getDepartment_id_text());
        if(model.getManager_idDirtyFlag())
            domain.setManager_id(model.getManager_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getParent_idDirtyFlag())
            domain.setParent_id(model.getParent_id());
        if(model.getMode_company_idDirtyFlag())
            domain.setMode_company_id(model.getMode_company_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getSecond_approver_idDirtyFlag())
            domain.setSecond_approver_id(model.getSecond_approver_id());
        if(model.getMeeting_idDirtyFlag())
            domain.setMeeting_id(model.getMeeting_id());
        if(model.getHoliday_status_idDirtyFlag())
            domain.setHoliday_status_id(model.getHoliday_status_id());
        if(model.getDepartment_idDirtyFlag())
            domain.setDepartment_id(model.getDepartment_id());
        if(model.getEmployee_idDirtyFlag())
            domain.setEmployee_id(model.getEmployee_id());
        if(model.getCategory_idDirtyFlag())
            domain.setCategory_id(model.getCategory_id());
        if(model.getFirst_approver_idDirtyFlag())
            domain.setFirst_approver_id(model.getFirst_approver_id());
        return domain ;
    }


}
